package main

import (
    "fmt"
)

type Context struct {
	Strategy Strategy
}
type Strategy interface {
	operate()
}

func (c *Context) operate() {
	c.Strategy.operate()
}

type Strategy1 struct {
	Strategy
}

func (s *Strategy1) operate() {
	fmt.Println("策略1")
}

type Strategy2 struct {
	Strategy
}

func (s *Strategy2) operate() {
	fmt.Println("策略2")
}

type Strategy3 struct {
	Strategy
}

func (s *Strategy3) operate() {
	fmt.Println("策略3")
}

func main() {
	c := &Context{new(Strategy2)}
	c.Strategy.operate()
}
